import { get, post, put, del } from "../utils/request";

//加载文章
export let loadEssayAPI = () => get("/api/article/list", { size: 2 });

//免费好课
export let loadCourseAPI = () => get("/api/freeCourse");

//获取验证码
export let getCodeAPI = (mobiles) =>
  get("/api/user_data/code", { mobile: mobiles });

//登录

export let LoginAPI = (mobiles, code) =>
  post("/api/user_data/login_v2", `mobile=${mobiles}&code=${code}`);

// 获取用户信息;
export let getUserAPI = () => get("/api/user_data/info");

// 题库;
export let loadBaseAPI = (id) => get("/api/category/query/" + id);

//套参数
export let loadTreeAPI = () => post("/api/combo2/combo2");

//更新用户资料
export let upUserDataAPI = (
  ids,
  sexs,
  eMails,
  usernames,
  nicknames,
  subjects,
  regions,
  schools,
  grades,
  headProtraits
) =>
  put("/api/user_data/update", {
    id: ids,
    sex: sexs,
    eMail: eMails,
    username: usernames,
    nickname: nicknames,
    subject: subjects,
    region: regions,
    school: schools,
    grade: grades,
    headProtrait: headProtraits,
  });

//del
export let delCart = (uid) => del("/api/scart/all/" + uid);

//上传用户头像
export let AddUserImgAPI = (data, files) =>
  post("/api/user_data/upload/avatar", data, { file: files });
